<template>
  <layout-slot :reArticle="reArticle">
    <article class="main-content page-page">
      <div class="post-header">
        <h1 class="post-title" itemprop="name headline">
          {{ pageInfo.title }} </h1>
        <div class="post-data">
          <time datetime="2020-04-27T23:04:00+08:00" itemprop="datePublished"><i class="fa fa-clock-o"
                                                                                 aria-hidden="true"> </i> {{
            pageInfo.date | dateFormat('{y}-{m}-{d}') }}
          </time>&nbsp;&nbsp; <i class="fa fa-comments-o" aria-hidden="true"></i> <a href="#comments"> {{ comments }}
          评论</a>&nbsp;&nbsp;
          <i class="fa fa-eye" aria-hidden="true"></i> {{ pageInfo.view }} 浏览
        </div>
      </div>
      <div id="post-content" class="post-content">
        <ul class="flinks" style="margin-left: -5px">
          <li v-for="item of links">
            <a :title="item.description" :href="item.url" target="_blank">
              <img alt="" :src="item.image">
              {{ item.title }}
            </a>
          </li>
        </ul>
        <div v-html="pageInfo.intro"></div>

      </div>
    </article>
    <twikoo/>
  </layout-slot>
</template>

<script>


  import { getCrossList, getLink } from '~/api/category'
  import { getMoviesDetail, getReArticle, recordCount } from '~/api'

  export default {
    name: 'links',

    data () {
      return {
        links: [],
        pageInfo: {
          views: 0,
          comments: 0,
          data: '2021/12/09',

        },
        reArticle: []
      }
    },
    computed: {
      comments () {
        return this.$store.state.comments
      }
    },
    methods: {},
    mounted () {

    },
    async asyncData ({ app, }) {
      let crossList = [], pageInfo = {}, links = []
      await getLink(app.$axios, { type: 0 }).then(({ data }) => {
        if (data.code === 200) {
          links = data.data
        }
      })
      await getMoviesDetail(app.$axios, { path: '/links' }).then(({ data }) => {
        if (data.data) {
          pageInfo = {
            intro: data.data.articleContent,
            date: data.data.articleUpdated,
            view: data.data.articleViewCount,
            comments: data.data.articleCommentCount,
            title: data.data.articleTitle
          }
          // 记录浏览量
          recordCount(app.$axios, { id: data.data.oId }).then((res) => {
          })

        }
      })
      let reArticle = await getReArticle(app)
      return {
        reArticle,
        pageInfo,
        links
      }
    }
  }
</script>

<style scoped>

</style>
